% TEST_ID: LANG-EXPAND-0122
% CATEGORY: language/string
% 测试 string 的转换构造器

function test_string_string()
s = 'abc';
newStr = string(s);
assert(isstring(newStr));
assert(isequal(newStr, "abc"));
assert(isa(newStr, 'string'));

s = {'abc'};
newStr = string(s);
assert(isstring(newStr));
assert(isequal(newStr, "abc"));
assert(isa(newStr, 'string'));


s = char(zeros(0,3));
newStr = string(s);
assert(isstring(newStr));
assert(isempty(newStr));
assert(isequal(size(newStr), [0, 1]));

s = char(zeros(3,0));
newStr = string(s);
assert(isstring(newStr));
assert(isequal(newStr, [""; ""; ""]));
assert(isequal(size(newStr), [3, 1]));

s = char(zeros(3,0,0));
newStr = string(s);
assert(isstring(newStr));
assert(isempty(newStr));
assert(isequal(size(newStr), [3 0]));

s = char(zeros(3,0,3));
newStr = string(s);
assert(isstring(newStr));
assert(isequal(newStr, strings(3,3)));
assert(isequal(size(newStr), [3 3]));

s = cell(3,0);
newStr = string(s);
assert(isstring(newStr));
assert(isempty(newStr));
assert(isequal(size(newStr), [3 0]));

s = zeros(0,3);
newStr = string(s);
assert(isstring(newStr));
assert(isempty(newStr));
assert(isequal(size(newStr), [0 3]));

s = strings(0,3);
newChr = char(s);
assert(ischar(newChr));
assert(isempty(newChr));
assert(isequal(size(newChr), [0 0 3]));

s = strings(3,0,0);
newChr = char(s);
assert(ischar(newChr));
assert(isempty(newChr));
assert(isequal(size(newChr), [3 0 0 0]));

s = string(char(zeros(3,0,3)));
newChr = char(s);
assert(ischar(newChr));
assert(isempty(newChr));
assert(isequal(size(newChr), [3 0 3]));
end